<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>

	<head>
		<base href="<%=basePath%>">
		<title>后台登录</title>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta name="author" content="CH.HUANG" />
		<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=Edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		
		<link rel="shortcut icon" href="assets/images/favicon.ico" />
		
		<link rel="stylesheet" type="text/css" href="assets/css/animate.min.css">
		<link href="assets/message/message.css" rel='stylesheet' type='text/css' />
		<!-- [if IE] > 
		<link href="assets/message/messageIE.css" rel='stylesheet' type='text/css' />
		<![endif] --> 
		<link href="assets/spop/spop.min.css" rel='stylesheet' type='text/css' />
		<link href="assets/loading/loading.css" rel='stylesheet' type='text/css' />
		
		<link href="assets/css/login.css" rel='stylesheet' type='text/css' />
		
		<script type="text/javascript" src="assets/js/jquery.min.js" ></script>
		<script type="application/x-javascript">
			addEventListener("load", function() {
				setTimeout(hideURLbar, 0);
			}, false);

			function hideURLbar() {
				window.scrollTo(0, 1);
			}
		</script>
	</head>

	<body>
		<h1>后台管理平台登录</h1>
		<div class="app-location">
			<div class="location">
				<!-- <img src="assets/images/logo.png" class="img-responsive" alt="" /> -->
			</div>
			<div class="form">
				<input id="username" name="username" data-background="tomato" type="text" class="text" placeholder="请输入用户名" />
				<input id="password" name="password" type="password" placeholder="请输入密码">
				<input id="verificationCode" name="verificationCode" type="text" maxlength="4" style="width: 40%;" placeholder="请输入验证码">
				<img alt="获取验证码" id="codeImg" class="codeImg" src="checkCode" onmouseover="this.style.cursor='pointer'">
				<script type="text/javascript">
					$(function(){
						$("#codeImg").click(function(){
							$("#codeImg").attr("src","checkCode?"+Math.random());
						});
					});
				</script>
				<div class="submit"><input id="loginButton" type="button" value="登录"></div>
				<div class="clear"></div>
			</div>
		</div>
		
		<!-- Javascript Libs -->
		<script type="text/javascript" src="assets/js/vue.min.js" ></script>
		<script type="text/javascript" src="assets/js/fetch.min.js" ></script>
		<script type="text/javascript" src="assets/message/message.js" ></script>
		<script type="text/javascript" src="assets/spop/spop.min.js" ></script>
		<script type="text/javascript" src="assets/loading/loading.js" ></script>
		<script type="text/javascript" src="assets/js/common.js"></script>
		<script type="text/javascript" src="assets/js/fetchFun.js"></script>
		
		<script>
			$(function(){
				$(document).keypress(function(e) {
			    	// 回车键事件  
			    	if(e.which == 13) {
			   			$("#loginButton").click();
			   		}
				});
				
				$('#loginButton').click(function(){
					var btn = this;
					
					var username = $('#username').val();
					if(isEmpty(username)){
						$.message({message:'用户名不能为空', type:'warning'});
						$('#username').focus();
						return false;
					}
					if(username.length>32){
						$.message({message:'用户名过长', type:'warning'});
						$('#username').focus();
						return false;
					}
					
					var password = $('#password').val();
					if(isEmpty(password)){
						$.message({message:'密码不能为空', type:'warning'});
						$('#password').focus();
						return false;
					}
					
					var verificationCode = $('#verificationCode').val();
					if(isEmpty(verificationCode)){
						$.message({message:'验证码不能为空', type:'warning'});
						$('#verificationCode').focus();
						return false;
					}
					if(verificationCode.length!=4){
						$.message({message:'验证码长度不正确', type:'warning'});
						$('#verificationCode').focus();
						return false;
					}
					
					post('system/login', function(data){
						if(data.success){
							location.href = 'pages/system/resource/resources.html';
						}else{
							spop(data.result, 'error');
						}
					}, {
						username: username,
						password: password,
						verificationCode: verificationCode
					});
				});
			});
		</script>
		
	</body>

</html>